package com.freewater.springboot.demo.ioc.qualifier.useannotation;

import com.freewater.springboot.demo.ioc.qualifier.MovieCatalog;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Getter
public class ComponentConfig {

    /**
     * Trying to inject the results from @Bean methods on the same configuration class is effectively a self-reference scenario as well.
     * 自动注入当前Configuration类中Bean方法返回的bean属于自引用注入
     */
    @Autowired
    private MovieCatalog movieCatalog;// 会注入movieCatalog1

    @Bean
    public MovieCatalog movieCatalog2() {
        return new MovieCatalog();
    }
}
